import java.util.concurrent.*;

//TIP 要<b>运行</b>代码，请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        MyThread t = new MyThread();
        t.setName("用继承实现线程");
        t.start();

        MyRunnable t1 = new MyRunnable();
        Thread T = new Thread(t1);
        T.setName("用Runnable实现线程");
        T.start();

        //创建单线程池
        ExecutorService Executor = Executors.newSingleThreadExecutor();
        //提交callable任务，获取future对象
        Future<Integer> future = Executor.submit(new MyCallable());
        //返回结果
        Integer result = future.get();
        System.out.println(result);
        //关闭线程池
        Executor.shutdown();



    }
}